/**
 * @example timeStrToSec('00:10:10') 
 */
export const timeStrToSec = (value) => {
    const val = value.split(':');
    const hour = parseInt(val[0]);
    const min = parseInt(val[1]);
    const sec = parseInt(val[2]);
    return (hour * 60 * 60) + (min * 60) + sec;
};

/**
 *  @example 
 *  timeBetweenTimeRange('00:10', '00:09', '00:10') ==> true
 *  timeBetweenTimeRange('00:10', '00:10', '00:10') ==> true
 *  timeBetweenTimeRange('00:10', '00:10', '00:09') ==> false
 *  timeBetweenTimeRange('00:10', '00:11', '00:10') ==> false
 */
export const timeIsBetweenTimeRange = (timeStr, startTimeStr, endTimeStr) => {
    //跨天
    if (timeStrToSec(startTimeStr) > timeStrToSec(endTimeStr)) {
        const endSec = timeStrToSec(endTimeStr) + 60 * 60 * 24;
        return timeStrToSec(timeStr) >= timeStrToSec(startTimeStr) && timeStrToSec(timeStr) <=
            endSec;
    }
    return timeStrToSec(timeStr) >= timeStrToSec(startTimeStr) && timeStrToSec(timeStr) <=
        timeStrToSec(endTimeStr)
};